﻿<AddDataFormTemplateSpec 
	xmlns="bb_appfx_adddataformtemplate"
	xmlns:common="bb_appfx_commontypes" 
	ID="c1d8245c-7f8a-49e9-874c-3a6e90884ce8" 
	Name="Service Bus Adapter Log Add Data Form"
	Description="Adds a record to the service bus adapter log" 
	Author="Blackbaud Professional Services"
	DataFormInstanceID="aeeb34ef-9228-4593-bbcb-11367f9f8e80" 
	RecordType="Service Bus Adapter Log"
	common:SecurityUIFolder="Service Bus Adapter"
	>

	<SPDataForm>
		<!-- describe the save SP -->
		<SaveImplementation SPName="USR_USP_DATAFORMTEMPLATE_ADD_SERVICEBUSADAPTERLOG">
			<common:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USR_USP_DATAFORMTEMPLATE_ADD_SERVICEBUSADAPTERLOG
(
  @ID uniqueidentifier = null output,
  @CHANGEAGENTID uniqueidentifier = null,
  @SERVERNAME nvarchar(100),
  @CORRELATIONID uniqueidentifier,
  @ENTRYTYPECODE tinyint,
  @DETAILS nvarchar(4000) = ''
)
as

set nocount on;

if @ID is null
    set @ID = newid()

if @CHANGEAGENTID is null  
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()

begin try
	-- handle inserting the data
	insert into 
    dbo.USR_SERVICEBUSADAPTERLOG
		  (ID, SERVERNAME, CORRELATIONID, ENTRYTYPECODE, DETAILS)
    values
		  (@ID, @SERVERNAME, @CORRELATIONID, @ENTRYTYPECODE, @DETAILS)
	
end try

begin catch
    exec dbo.USP_RAISE_ERROR
    return 1
end catch

return 0				
				]]>
			</common:CreateProcedureSQL>
		</SaveImplementation>
	</SPDataForm>

	<!-- describe fields on the form, which correspond to parameters on the SP.  Note that system parameters 
	like the context @ID, @CONTEXTID, and @CURRENTAPPUSERID need not be listed. -->
	<common:FormMetaData FixedDialog="true">
		<common:FormFields>
			<common:FormField FieldID="SERVERNAME" Caption="Server name" DataType="String" MaxLength="100" Required="true" />
			<common:FormField FieldID="CORRELATIONID" Caption="Correlation ID" DataType="Guid" Required="true" />
      <common:FormField FieldID="ENTRYTYPECODE" Caption="Entry type" DataType="TinyInt" Required="true">
        <common:ValueList>
          <common:Items>
            <common:Item>
              <common:Value>1</common:Value>
              <common:Label>Error</common:Label>
            </common:Item>
            <common:Item>
              <common:Value>2</common:Value>
              <common:Label>Warning</common:Label>
            </common:Item>
            <common:Item>
              <common:Value>4</common:Value>
              <common:Label>Information</common:Label>
            </common:Item>
          </common:Items>
        </common:ValueList>
      </common:FormField>
      <common:FormField FieldID="DETAILS" Caption="Details" DataType="String" MaxLength="4000" />
		</common:FormFields>
    
		<!-- indicate the client-side component for the user interface -->
    <common:WebUIComponent>
      <common:WebUI>
        <common:DefaultWebUI/>
      </common:WebUI>
    </common:WebUIComponent>
	</common:FormMetaData>

</AddDataFormTemplateSpec>